import pygame,random,time#
lu=[]
gai=[25,50,75,25]
y1=110
y2=120
pygame.init()#
screen=pygame.display.set_mode([500,500])#
screen.fill([0,0,0])#
def shua():#
    pygame.display.flip()#
running=True#
while running:#
    for event in pygame.event.get():#
        if event.type==pygame.QUIT:#
            running=False#
    pygame.draw.rect(screen,[255,0,0],[100,100,10,10],0)
    pygame.draw.rect(screen,[0,255,0],[y1,y1,y2-y1,y2-y1],0)
    for i in range(50):
        x=21
        w=[100,100,0,0,0,0,0]
        while x>0:
            x-=1
            y=random.randint(0,100)
            x1=random.randint(-1,1)
            x2=random.randint(-1,1)
            x3=random.randint(-1,1)
            gai=[0+x1,49+x2,51+x3]
            if y<=gai[0]:
                w[0]-=1
                w[2]+=1
            if gai[0]<y<=gai[1]:
                w[0]+=1
                w[3]+=1
            if gai[1]<y<=gai[2]:
                w[1]-=1
                w[4]+=1
            if y>gai[2]:
                w[1]+=1
                w[5]+=1

            pygame.draw.rect(screen,[5*i,5*i,5*i],[w[0],w[1],1,1],0)
            time.sleep(0.005)
            shua()
            if y1<=w[0]<=y2 and y1<=w[1]<=y2:
                w[6]+=x
                w.append(gai)
                x=-1
        lu.append (w)
    shua()#
    running=False
for i in range(50):
    if lu[i-1][6]>0:
        print(lu[i-1])
pygame.quit()#





